import axios from "axios";
import { useStore } from "../store";
import { localStorageUtil } from '../store/storage'

const BASE_URL = `http://${window.location.hostname}:9010/api/`;

const createRequest = async (api, data) => {
  // let store = useStore();
  // debugger;
  // var auth = localStorageUtil.get("access-token");
  return await axios({
    method: "POST",
    url: BASE_URL + api,
    headers: {
      "Content-Type": "application/json",
      Authorization: localStorageUtil.get("access-token")
      // store.user.token ?? localStorageUtil.get("access-token")
    },
    data: JSON.stringify(data),
  });
};

export default createRequest;
